#include "SemanticNode.h"

#include "main2.h"


SemanticNode::SemanticNode(SemanticNode* parent) : parent(parent) { }

SemanticNode::~SemanticNode() { }

std::string SemanticNode::toDebugString(int tab) {
	std::ostringstream ss;
	for (int i = 0; i < tab; i++)
		ss << DEBUG_STRING_RAZMAK;
	ss << "TODO" << std::endl;
	return ss.str();
}





std::string SemanticNode::flattenNamePeriodAdd(const SyntaxTreeNode& nameNode) {
	std::ostringstream ss;
	LexicUnit lu = CompilerData->Units->GetLexicUnit(nameNode.Nodes->GetData(0)->LexUnitID);
	ss << CompilerData->Units->GetLexicUnitString(&lu);
	for (int i = 0; i < nameNode.Nodes->GetData(1)->Nodes->GetCount(); i++) {
		lu = CompilerData->Units->GetLexicUnit(nameNode.Nodes->GetData(1)->Nodes->GetData(i)->Nodes->GetData(1)->LexUnitID);
		ss << "." << CompilerData->Units->GetLexicUnitString(&lu);
	}
	return ss.str();
}

std::vector<std::string> SemanticNode::flattenTemplateIdentifiers(const SyntaxTreeNode &templateUseNode) {
	// also flattens <enum_names> node
	std::vector<std::string> result;
	result.push_back(CompilerData->Units->GetLexicUnitString(&CompilerData->Units->GetLexicUnit(templateUseNode.Nodes->GetData(0)->LexUnitID)));
	SyntaxTreeNode *Current = templateUseNode.Nodes->GetData(1);
	for (int x = 0; x < Current->Nodes->GetCount(); ++x) {
		result.push_back(CompilerData->Units->GetLexicUnitString(&CompilerData->Units->GetLexicUnit(Current->Nodes->GetData(x)->Nodes->GetData(1)->LexUnitID)));
	}
	return result;
}












//TODO brisi
int SemanticNode::getNextUniqueID(void) {
	return 0;
 //return parent->getNextUniqueID();
}
